package com.cyt.web.controller.wx;

import cn.hutool.core.util.StrUtil;
import com.cyt.base.enums.BusinessType;
import com.cyt.base.enums.OperatorType;
import com.cyt.base.model.dto.ReturnResult;
import com.cyt.wx.model.vo.WxApplyUseCategoryVo;
import com.cyt.wx.service.WxApplyUseCategoryService;
import com.cyt.sys.aspect.BaseLog;
import com.cyt.web.controller.base.BaseController;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 微信应用分类关联-微信应用分类关联控制层
 *
 * @author congcong tao
 * @date 2019-8-14 10:37:24
 */
@RestController
public class WxApplyUseCategoryController extends BaseController {

    @Resource
    private WxApplyUseCategoryService wxApplyUseCategoryService;
    
    /**
     * 统一跳转
     *
     * @param model 数据模型
     * @return Model
     * @author congcong tao
     * @date 2019-8-14 10:37:24
     */
    @RequestMapping("/wx/wxapplyusecategory/*")
    public Model goPage(Model model) {
        return model;
    }

    /**
     * 分页查询
     *
     * @param wxApplyUseCategoryVo 接受参数对象
     * @param page 分页数
     * @param limit 每页显示条数
     * @return ReturnResult
     * @author congcong tao
     * @date 2019-8-14 10:37:24
     */
    @BaseLog(module = "微信应用分类关联", classz = "微信应用分类关联", methods = "分页查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/wx/wxapplyusecategory/findPage", method = RequestMethod.POST)
    public ReturnResult findPage(WxApplyUseCategoryVo wxApplyUseCategoryVo, int page, int limit) {
        return wxApplyUseCategoryService.findPage(wxApplyUseCategoryVo, page, limit);
    }

    /**
     * 分页查询
     *
     * @param wxApplyUseCategoryVo 接受参数对象
     * @param page 分页数
     * @param limit 每页显示条数
     * @return ReturnResult
     * @author congcong tao
     * @date 2019-8-14 10:37:24
     */
    @BaseLog(module = "微信应用分类关联", classz = "微信应用分类关联", methods = "分页查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/wx/wxapplyusecategory/findVoPage", method = RequestMethod.POST)
    public ReturnResult findVoPage(WxApplyUseCategoryVo wxApplyUseCategoryVo, int page, int limit) {
        return wxApplyUseCategoryService.findVoPage(wxApplyUseCategoryVo, page, limit);
    }

    /**
     * list查询
     *
     * @param wxApplyUseCategoryVo 接受参数对象
     * @return ReturnResult
     * @author congcong tao
     * @date 2019-8-14 10:37:24
     */
    @BaseLog(module = "微信应用分类关联", classz = "微信应用分类关联", methods = "list查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/wx/wxapplyusecategory/findList", method = RequestMethod.POST)
    public ReturnResult findList(WxApplyUseCategoryVo wxApplyUseCategoryVo) {
        return new ReturnResult(wxApplyUseCategoryService.findList(wxApplyUseCategoryVo));
    }

    /**
     * list查询
     *
     * @param wxApplyUseCategoryVo 接受参数对象
     * @return ReturnResult
     * @author congcong tao
     * @date 2019-8-14 10:37:24
     */
    @BaseLog(module = "微信应用分类关联", classz = "微信应用分类关联", methods = "list查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/wx/wxapplyusecategory/findVoList", method = RequestMethod.POST)
    public ReturnResult findVoList(WxApplyUseCategoryVo wxApplyUseCategoryVo) {
        return new ReturnResult(wxApplyUseCategoryService.findVoList(wxApplyUseCategoryVo));
    }

    /**
     * 单个对象查询
     *
     * @param wxApplyUseCategoryVo 接受参数对象
     * @return ReturnResult
     * @author congcong tao
     * @date 2019-8-14 10:37:24
     */
    @BaseLog(module = "微信应用分类关联", classz = "微信应用分类关联", methods = "one查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/wx/wxapplyusecategory/findOne", method = RequestMethod.POST)
    public ReturnResult findOne(WxApplyUseCategoryVo wxApplyUseCategoryVo) {
        return new ReturnResult(wxApplyUseCategoryService.findOne(wxApplyUseCategoryVo));
    }

    /**
     * 单个对象查询
     *
     * @param wxApplyUseCategoryVo 接受参数对象
     * @return ReturnResult
     * @author congcong tao
     * @date 2019-8-14 10:37:24
     */
    @BaseLog(module = "微信应用分类关联", classz = "微信应用分类关联", methods = "one查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/wx/wxapplyusecategory/findVoOne", method = RequestMethod.POST)
    public ReturnResult findVoOne(WxApplyUseCategoryVo wxApplyUseCategoryVo) {
        return new ReturnResult(wxApplyUseCategoryService.findVoOne(wxApplyUseCategoryVo));
    }

    /**
     * 跳转添加或编辑界面
     *
     * @param wxApplyUseCategoryVo 接受参数对象
     * @return ReturnResult
     * @author congcong tao
     * @date 2019-8-14 10:37:24
     */
    @BaseLog(module = "微信应用分类关联", classz = "微信应用分类关联", methods = "跳转添加或编辑界面", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/wx/wxapplyusecategory/getEdit", method = RequestMethod.GET)
    public ModelAndView getEdit(WxApplyUseCategoryVo wxApplyUseCategoryVo) {
        ModelAndView view = new ModelAndView("/wx/wxapplyusecategory/wxApplyUseCategoryEdit");
        if (StrUtil.isNotEmpty(wxApplyUseCategoryVo.getId())) {
            view.addObject(wxApplyUseCategoryService.findVoOne(wxApplyUseCategoryVo));
        }
        return view;
    }

    /**
     * 保存或更新
     *
     * @param request 请求对象
     * @param wxApplyUseCategoryVo 接受参数对象
     * @return ReturnResult
     * @author congcong tao
     * @date 2019-8-14 10:37:24
     */
    @BaseLog(module = "微信应用分类关联", classz = "微信应用分类关联", methods = "保存或更新对象", businessType = BusinessType.INSERT, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/wx/wxapplyusecategory/addOrUpdate", method = RequestMethod.POST)
    public ReturnResult addOrUpdate(HttpServletRequest request, WxApplyUseCategoryVo wxApplyUseCategoryVo) {
        return wxApplyUseCategoryService.addOrUpdate(wxApplyUseCategoryVo, acceptCurrentUser(request));
    }

    /**
     * 根据条件逻辑删除
     *
     * @param request 请求对象
     * @param wxApplyUseCategoryVo 接受参数对象
     * @return ReturnResult
     * @author congcong tao
     * @date 2019-8-14 10:37:24
     */
    @BaseLog(module = "微信应用分类关联", classz = "微信应用分类关联", methods = "逻辑删除对象", businessType = BusinessType.DELETE, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/wx/wxapplyusecategory/remove", method = RequestMethod.GET)
    public ReturnResult remove(HttpServletRequest request, WxApplyUseCategoryVo wxApplyUseCategoryVo) {
        return wxApplyUseCategoryService.remove(wxApplyUseCategoryVo, acceptCurrentUser(request));
    }

    /**
     * 根据条件物理删除
     *
     * @param request 请求对象
     * @param wxApplyUseCategoryVo 接受参数对象
     * @return ReturnResult
     * @author congcong tao
     * @date 2019-8-14 10:37:24
     */
    @BaseLog(module = "微信应用分类关联", classz = "微信应用分类关联", methods = "物理对象对象", businessType = BusinessType.DELETE, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/wx/wxapplyusecategory/delete", method = RequestMethod.GET)
    public ReturnResult delete(HttpServletRequest request, WxApplyUseCategoryVo wxApplyUseCategoryVo) {
        return wxApplyUseCategoryService.delete(wxApplyUseCategoryVo, acceptCurrentUser(request));
    }
}